<?php
Yii::import('dao.auction.AuctionCacheData');
Yii::import('dao.auction.AuctionDao');
class CCacheAuctionDataProvider extends CActiveDataProvider{
    protected function fetchData()
    {
        $this->getCriteria()->select = 'auction_id';
        $data =  parent::fetchData();
        
        /**
         *  如果后台设置show显示，否则不显示 
         */
        /* $newdata=array();
        foreach ($data as $auctiondata){
            $auctionDao=new AuctionDao();
            $auctionDao->find($auctiondata->auction_id);
            if ($auctionDao->show){
                $newdata[]=$auctiondata;
            }    
        } */
        $newdata=$data;
        if(!empty($newdata)){
            foreach ($newdata as &$auctionData){
                $auctionCache = new AuctionCacheData();
                $auctionCacheData = $auctionCache->findGNCByPk($auctionData->auction_id);   
                $auctionData->attributes = $auctionCacheData->attributes;
            }

        }
        return $newdata;
    }
}